.text 
.global _start
_start:
@R0 存放寄存器在内存中的map地址
@R1 存放寄存器的值
 
@1 配置RCC: LD1、LD2、LD3和蜂鸣器的使能
ldr R0, =(0x50000000+0xA28)
ldr R1, [R0]
orr R1, R1, #0x32
str R1, [R0]
 
@2 配置MODER寄存器
@2.1 配置LED1、LED3
ldr R0, =0x50006000
ldr R1, [R0]
bic R1, #(0x33<<16)
orr R1, #(0x11<<16)
str R1, [R0]
@2.2 配置LED2
ldr R0, =0x50007000
ldr R1, [R0]
bic R1, #(0x3<<20)
orr R1, #(0x1<<20)
str R1, [R0]
@2.3 配置蜂鸣器
ldr R0, =0x50003000
ldr R1, [R0]
bic R1, #(0x3<<12)
orr R1, #(0x1<<12)
str R1, [R0]
 
@3 配置OTYPER寄存器
@3.1 配置LED1、LED3
ldr R0, =(0x50006000+0x04)
ldr R1, [R0]
bic R1, #(0x5<<8)
str R1, [R0]
@3.2 配置LED2
ldr R0, =(0x50007000+0x04)
ldr R1, [R0]
bic R1, #(0x1<<10)
str R1, [R0]
@3.3 配置蜂鸣器
ldr R0, =(0x50003000+0x04)
ldr R1, [R0]
bic R1, #(0x1<<6)
str R1, [R0]
 
@4 配置OSPEEDR寄存器
@4.1 配置LED1、LED3
ldr R0, =(0x50006000+0x08)
ldr R1, [R0]
bic R1, #(0x33<<16)
str R1, [R0]
@4.2 配置LED2
ldr R0, =(0x50007000+0x08)
ldr R1, [R0]
bic R1, #(0x3<<20)
str R1, [R0]
@4.3 配置蜂鸣器
ldr R0, =(0x50003000+0x08)
ldr R1, [R0]
bic R1, #(0x3<<12)
str R1, [R0]
 
@5 配置PUPDR寄存器
@5.1 配置LED1、LED3
ldr R0, =(0x50006000+0x0C)
ldr R1, [R0]
bic R1, #(0x33<<16)
str R1, [R0]
@5.2 配置LED2
ldr R0, =(0x50007000+0x0C)
ldr R1, [R0]
bic R1, #(0x3<<20)
str R1, [R0]
@5.3 配置蜂鸣器
ldr R0, =(0x50003000+0x0C)
ldr R1, [R0]
bic R1, #(0x3<<12)
str R1, [R0]
 
@死循环让
loop:
	@bl bee_off
	bl led1_on
	bl delay	
	bl led1_off
	bl led2_on
	bl delay
	bl led2_off
	bl led3_on
	bl delay
	bl led3_off
	@bl bee_on
	bl delay
	b loop
 
delay:
	mov R10, #0x10000000
d2:
	sub R10, R10, #1
	cmp R10, #0
	bne d2
	mov PC, LR
 
led1_on:
ldr R0, =(0x50006000+0x14)
ldr R1, [R0]
orr R1, #(0x1<<10)
str R1, [R0]
mov PC, LR
 
led2_on:
ldr R0, =(0x50007000+0x14)
ldr R1, [R0]
orr R1, #(0x1<<10)
str R1, [R0]
mov PC, LR
 
led3_on:
ldr R0, =(0x50006000+0x14)
ldr R1, [R0]
orr R1, #(0x1<<8)
str R1, [R0]
mov PC, LR
 
bee_on:
ldr R0, =(0x50003000+0x14)
ldr R1, [R0]
orr R1, #(0x1<<6)
str R1, [R0]
mov PC, LR
 
led1_off:
ldr R0, =(0x50006000+0x14)
ldr R1, [R0]
bic R1, #(0x1<<10)
str R1, [R0]
mov PC, LR
 
led2_off:
ldr R0, =(0x50007000+0x14)
ldr R1, [R0]
bic R1, #(0x1<<10)
str R1, [R0]
mov PC, LR
 
led3_off:
ldr R0, =(0x50006000+0x14)
ldr R1, [R0]
bic R1, #(0x1<<8)
str R1, [R0]
mov PC, LR
 
bee_off:
ldr R0, =(0x50003000+0x14)
ldr R1, [R0]
bic R1, #(0x1<<6)
str R1, [R0]
mov PC, LR
 
.end
